<template>
  <view class="setting_container">
    <view class="unified" @click="clickItemInfo('basicInformation')">
      <text>基本信息</text>
      <img :src="staticUrl() + '/setting/right.png'" alt="" />
    </view>
    <view class="unified" @click="clickItemInfo('addressManagement')">
      <text>地址管理</text>
      <img :src="staticUrl() + '/setting/right.png'" alt="" />
    </view>
    <view class="unified" @click="clickItemInfo('changPassword')">
      <text>修改密码</text>
      <img :src="staticUrl() + '/setting/right.png'" alt="" />
    </view>
    <view class="unified" @click="clickItemInfo('settingPassword')">
      <text>设置支付密码</text>
      <img :src="staticUrl() + '/setting/right.png'" alt="" />
    </view>
    <view class="unified" @click="
        clickItem(
          'webView',
          'https://www.xdyy100.com/wholesale/essential/common/agreement/classify/ABOUT_US/content',
          '关于我们'
        )
      ">
      <text>关于我们</text>
      <img :src="staticUrl() + '/setting/right.png'" alt="" />
    </view>
    <view class="unified" @click="
        clickItem(
          'webView',
          'https://www.xdyy100.com/wholesale/essential/common/agreement/classify/SERVICE/content',
          '隐私政策'
        )
      ">
      <text>隐私政策</text>
      <img :src="staticUrl() + '/setting/right.png'" alt="" />
    </view>
    <!-- #ifndef MP -->
    <view class="unified" @click="
        clickItem(
          'webView',
          'https://www.xdyy100.com/wholesale/essential/common/agreement/classify/REGISTRATION/content',
          '注销账号'
        )
      ">
      <text>注销账号</text>
      <img :src="staticUrl() + '/setting/right.png'" alt="" />
    </view>
    <!-- #endif -->
    <view class="unified" @click="clearCache">
      <text>清除缓存</text>
      <img :src="staticUrl() + '/setting/right.png'" alt="" />
    </view>
    <view class="unified">
      <text>当前版本</text>
      <text>V{{ version }}</text>
    </view>

    <view class="logOut" @click="logOut"> 退出登录 </view>
  </view>
</template>

<script>
export default {
  data () {
    return {
      version: ''
    }
  },
  created () {
    this.version = uni.getStorageSync('version')
  },
  methods: {
    clearCache () {
      uni.removeStorageSync("getA")
      uni.removeStorageSync("searchHistory")
      uni.setStorageSync("advertisementLength", 0)
      uni.showToast({ icon: 'none', title: '清理完成' })
    },
    clickItem (path, url, title) {
      uni.navigateTo({
        url: `/pages/mySetting/${path}?url=${url}&title=${title}`
      })
    },
    clickItemInfo (path, url, title) {
      uni.navigateTo({
        url: `/pages_user/setting/${path}?url=${url}&title=${title}`
      })
    },
    logOut () {
      uni.removeStorageSync('token')
      uni.switchTab({
        url: '/pages/index/index',
        success: res => {
          uni.$emit('update', '更新首页')
          // let page = getCurrentPages().pop()
          // if (page == undefined || page == null) return
          // page.onLoad()
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.setting_container {
  background: #f9f9f9;
  height: 100vh;
}

.unified {
  font-size: 26rpx;
  opacity: 0.6;
  display: flex;
  width: 100%;
  flex-flow: row nowrap;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #f9f9f9;

  text {
    padding: 40rpx 50rpx;
  }

  img {
    width: 8rpx;
    height: 16rpx;
    padding-right: 50rpx;
  }
}

.unified:nth-child(2n) {
  margin-bottom: 20rpx;
}

.logOut {
  width: 80%;
  font-size: 30rpx;
  padding: 20rpx;
  background: #fff;
  text-align: center;
  margin: 0 auto;
  margin-top: 250rpx;
  border-radius: 50rpx;
}
</style>
